package cn.ljy.mes.model;

import cn.ljy.authority.model.SysUser;
import cn.ljy.common.model.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 库存锁定数量表实体类<br/>
 * 对应表：wms_material_inventory_detail_lock_log<br/>
 * 用于记录智能仓储WMS中，生产/商城工单触发的物料库存锁定/解锁操作明细
 */
@ApiModel(value = "库存锁定数量记录", description = "记录生产/商城工单的物料库存锁定/解锁操作")
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false, of = {"id"})
public class WmsMaterialInventoryDetailLockLog extends BaseModel {

    @ApiModelProperty(value = "编号（UUID）", example = "01f15383-7cb4-11f0-92a2-0250f2000002")
    private String id;

    @ApiModelProperty(value = "商城工单号（用于追溯锁定的业务源）,仅用于数据库检索，不作为查询条件、插入、更新、删除的依据字段", example = "SHOP-20250907-001")
    private String shopOrderId;
    @ApiModelProperty(value = "商城工单")
    private ShopCarOrder carOrder;

    @ApiModelProperty(value = "生产订单号（用于追溯锁定的业务源），仅用于数据库检索，不作为查询条件、插入、更新、删除的依据字段", example = "PROD-20250907-001")
    private String productionOrderId;
    @ApiModelProperty(value = "生产工单")
    private MesProductionOrder productionOrder;

    @ApiModelProperty(value = "物料批号ID（关联wms_material_batch表），仅用于数据库检索，不作为查询条件、插入、更新、删除的依据字段", required = true, example = "MATERIAL-20250907-001")
    private String materialBatchId;
    @ApiModelProperty(value = "物料批次")
    private WmsMaterialBatch materialBatch;

    @ApiModelProperty(value = "锁库/解锁库位ID（关联wms_warehouse_seat表）", required = true, example = "SEAT-20250907-001")
    private String seatId;
    @ApiModelProperty(value = "库位对象")
    private WmsWarehouseSeat warehouseSeat;


    @ApiModelProperty(value = "仓库名称（冗余字段，存档历史记录）", required = true, example = "一号仓库")
    private String warehouse;

    @ApiModelProperty(value = "源库区名称（冗余字段，存档历史记录）", required = true, example = "A区")
    private String area;

    @ApiModelProperty(value = "源库位名称（冗余字段，存档历史记录）", required = true, example = "A1库位")
    private String seat;

    @ApiModelProperty(value = "锁库/解锁类型（lock:锁库; unlock:解锁）", required = true, example = "lock")
    private String lockType;

    @ApiModelProperty(value = "锁库/解锁前可用库存", required = true, example = "100")
    private Long inventory;

    @ApiModelProperty(value = "锁库/解锁前的已锁定量", required = true, example = "20")
    private Long preLockedQuantity;

    @ApiModelProperty(value = "变动量（正数，应用层根据lock/unlock解析为正负数）", required = true, example = "30")
    private Long deltaQuantity;

    @ApiModelProperty(value = "执行人ID（关联sys_user表）", required = true, example = "1")
    private Long executorId;
    @ApiModelProperty(value = "执行人")
    private SysUser executor;

    @ApiModelProperty(value = "锁库/解锁原因", example = "生产工单需求")
    private String reason;

    @ApiModelProperty(value = "锁库/解锁时间", required = true, example = "2025-09-07 14:30:00")
    private Date createTime;

    // 非数据库字段（用于前端展示）
    @ApiModelProperty(value = "操作员姓名（冗余，用于查询结果展示）")
    private String operatorName;
    @ApiModelProperty(value = "物料名（冗余，用于查询结果展示）")
    private String materialName;
    @ApiModelProperty(value = "物料类别名称（冗余，用于查询结果展示）")
    private String materialTypeName;
    @ApiModelProperty(value = "物料批次（冗余，用于查询结果展示）")
    private String batchNumber;
    @ApiModelProperty(value = "锁定数量变化。（冗余，用于查询结果展示）")
    private String deltaQuantityString;
}